import { request } from "@/request";

export async function fetchList(data) {
  const res = await request("/admin/mallOrder/pageList", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}
export async function fetchOtherOrderList(data) {
  const res = await request("/admin/otherOrder/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}

// 待付款-取消订单
export function cancelOrder_waitPay(data) {
  return request(`/admin/mallOrder/cancelOrder_waitPay`, {
    method: "POST",
    data,
  });
}

// 待发货-取消订单
export function cancelOrder_isPay(data) {
  return request(`/admin/mallOrder/cancelOrder_isPay`, {
    method: "POST",
    data,
  });
}
// 订单详情
export function orderDetail(data) {
  return request(`/admin/mallOrder/orderDetail`, {
    method: "POST",
    data,
  });
}
// 发货
export function deliver_goods(data) {
  return request(`/admin/mallOrder/deliver_goods`, {
    method: "POST",
    data,
  });
}

// 打印运单
export function getPullData(data) {
  return request(`/admin/mallOrder/getPullData`, {
    method: "POST",
    data,
  });
}

// 老师订单-核销
export function writeOff(data) {
  return request(`/admin/otherOrder/writeOff`, {
    method: "POST",
    data,
  });
}
// 老师订单-退款
export function refund(data) {
  return request(`/admin/otherOrder/refund`, {
    method: "POST",
    data,
  });
}

// 智能穿戴-发货
export function deliverySubmitJdOrderOther(data) {
  return request(`/admin/otherOrder/deliverySubmitJdOrder`, {
    method: "POST",
    data,
  });
}
// 智能穿戴-打印运单
export function getPrintDataOther(data) {
  return request(`/admin/otherOrder/getPrintData`, {
    method: "POST",
    data,
  });
}


// 售后订单
export async function fetchRefundsList(data) {
  const res = await request("/admin/refunds/pageList", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}
// 售后订单-审核
export function approval(data) {
  return request(`/admin/refunds/approval`, {
    method: "POST",
    data,
  });
}

// 售后订单-收货
export function pass(data) {
  return request(`/admin/refunds/pass`, {
    method: "POST",
    data,
  });
}
// 售后订单-换货发货
export function deliverChangeGoods(data) {
  return request(`/admin/refunds/deliverChangeGoods`, {
    method: "POST",
    data,
  });
}

// 书包订单
export async function fetchPackageList(data) {
  const res = await request("/admin/schoolBagOrder/pageQuery", {
    method: "POST",
    data,
  });
  return {
    data: res?.data?.list,
    total: res?.data?.total,
    success: true,
  };
}

export function fetchPackageInfo(data) {
  return request(`/admin/schoolBagOrder/get/${data.orderId}`, {
    method: "POST",
    data,
  });
}

export function fetchAddressList(data) {
  return request(`/admin/userAddress/listQuery`, {
    method: "POST",
    data,
  });
}

export function updateAddress(data) {
  return request(`/admin/schoolbagOrderReadRecord/update`, {
    method: "POST",
    data,
  });
}
// 书包订单-发货
export function deliverySubmitJdOrder(data) {
  return request(`/admin/schoolBagOrder/deliverySubmitJdOrder`, {
    method: "POST",
    data,
  });
}
// 书包订单-打印物流面单
export function getPrintData(data) {
  return request(`/admin/schoolBagOrder/getPrintData`, {
    method: "POST",
    data,
  });
}

// 书包订单-下回收的物流单
export function recoverySubmitJdOrder(data) {
  return request(`/admin/schoolBagOrder/recoverySubmitJdOrder`, {
    method: "POST",
    data,
  });
}
// 书包订单-押金扣除
export function withholdingDeposit(data) {
  return request(`/admin/schoolbagOrderReadRecord/withholdingDeposit`, {
    method: "POST",
    data,
  });
}
// 书包发货查询
export function getOrderInfoByRasId(data) {
  return request(`/admin/schoolBagOrder/getOrderInfoByRasId`, {
    method: "POST",
    data,
  });
}
// 书包发货查询
export function getWaitDeliveryOrderInfoByRasId(data) {
  return request(`/admin/schoolBagOrder/getWaitDeliveryOrderInfoByRasId`, {
    method: "POST",
    data,
  });
}
// 书包收货查询
export function getWaitCollectOrderInfoByRasId(data) {
  console.log('-----------')
  return request(`/admin/schoolBagOrder/getWaitCollectOrderInfoByRasId`, {
    method: "POST",
    data,
  });
}

// 确认收货
export function recoveryCheck(data) {
  return request(`/admin/schoolBagOrder/recoveryCheck`, {
    method: "POST",
    data,
  });
}

// 书包订单-审核
export function afterSaleAudit(data) {
  return request(`/admin/schoolBagOrder/afterSaleAudit`, {
    method: "POST",
    data,
  });
}
